--暴风号令
local baofenghaoling = fk.CreateSkill {
    name = "mcdh_baofenghaoling"
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

baofenghaoling:addEffect('active',{
    can_use = function(self, player)
        return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
    end,
    on_use = function(self, room, effect)
        local player = effect.from
        room:damage({
            from = nil,
            to = player,
            damage = 1,
            skillName = self.name,
        })
        player:drawCards(player:getLostHp(),self.name)
        local use = U.askForPlayCard(room,player,nil,".",self.name,"#baofenghaoling",{bypass_distances = true,bypass_times = true},true,true)
        if use then
            use.extraUse = true
            use.extra_data = use.extra_data or {}
            use.extra_data.baofenghaoling = player.id
            room:useCard(use)
        end
    end
})

baofenghaoling:addEffect(fk.CardUseFinished,{
    is_delay_effect = true,
    can_trigger = function(self,event,target,player,data)
        return data.extra_data and data.extra_data.baofenghaoling == player.id and
                data.damageDealt
    end,
    on_cost = function(self,event,target,player,data)
        return true
    end,
    on_use = function(self,event,target,player,data)
        local room = player.room
        room:addPlayerMark(player,MarkEnum.AddMaxCardsInTurn,1)
    end
})

Fk:loadTranslationTable {
    ["mcdh_baofenghaoling"] = "暴风号令",
    [":mcdh_baofenghaoling"] = "出牌阶段限一次，你可以受到1点无来源伤害并X张牌，然后你可以不计入次数且无距离次数限制的使用一张牌，若此牌造成伤害，本回合你的手牌上限+1。(X为你已损失体力值)",
    ["#baofenghaoling"] = "暴风号令:无距离、次数限制的使用一张牌"
}

return baofenghaoling